package com.edu.exam.enums.grading.integration;

/**
 * 数据源类型枚举
 * 
 * 定义数据源的不同类型
 */
public enum SourceType {
    REST_API("rest_api", "REST API接口"),
    FILE_UPLOAD("file_upload", "文件上传"),
    DATABASE("database", "数据库"),
    MESSAGE_QUEUE("message_queue", "消息队列"),
    WEB_SERVICE("web_service", "Web服务");

    private final String code;
    private final String description;

    SourceType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static SourceType fromCode(String code) {
        for (SourceType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return REST_API;
    }
}